<!-- 会员中心的菜单 -->
<ul class="layui-nav layui-nav-tree layui-inline" lay-filter="user" id="menuList">
  <li class="layui-nav-item">
    <a href="{:url('home/user/index',['userid' => $Think.cookie.LoginUser['id']])}" class="abtn">
      <i class="layui-icon">&#xe609;</i>
      我的主页
    </a>
  </li>
  <li class="layui-nav-item layui-this">
    <a href="{:url('home/user/user')}" class="abtn">
      <i class="layui-icon">&#xe620;</i>
      基本设置
    </a>
  </li>
  <li class="layui-nav-item">
    <a href="{:url('home/user/post')}" class="abtn">
      <i class="layui-icon">&#xe611;</i>
      我的帖子
    </a>
  </li>
  <li class="layui-nav-item">
    <a href="{:url('home/user/collect')}" class="abtn">
      <i class="layui-icon">&#xe611;</i>
      我的收藏
    </a>
  </li>
  <li class="layui-nav-item">
    <a href="{:url('home/user/record')}" class="abtn">
      <i class="layui-icon">&#xe611;</i>
      积分消费记录
    </a>
  </li>
</ul>

<script>
  var menuList = document.querySelector("#menuList").children;
  var aList = document.querySelectorAll('.abtn');
  var pathname = window.location.pathname;

  for (let i = 0; i < menuList.length; i++) {
    menuList[i].classList.remove("layui-this");
  }

  for (let i = 0; i < aList.length; i++) {
    if (aList[i].attributes["href"].value == pathname) {
      menuList[i].classList.add("layui-this");
    }
  }


</script>